home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / getkey.arc / GETKEY.DOC < prev    next >
Text File  |  1989-02-22  |  5KB  |  192 lines

  1.        ________________________________________________________________
  2.  
  3.                              GETKEY DOCumentation
  4.        ________________________________________________________________
  5.  
  6.        GETKEY  is  used in batch files to get keys from the keyboard and
  7.        exit with an ERRORLEVEL that can then be tested.  A  prompt  line
  8.        can  be  displayed.   Any  alphanumeric  character can be a valid
  9.        response but valid responses must be  specified  on  the  command
  10.        line.   An Enter exits with an ERRORLEVEL equal to the last valid
  11.        response character on the command line.  By using the /F  command
  12.        line  option, all unshifted function keys become valid responses.
  13.        Non-valid responses cause the bell to be sounded.
  14.  
  15.  
  16.  
  17.        Command line format:
  18.  
  19.        GETKEY [/F] "prompt" [xyz]
  20.  
  21.        where xyz are valid  response  characters.   All  characters  are
  22.        converted  to  uppercase  so  you do not have to worry about case
  23.        conversion.   The  last  character entered will be the default if
  24.        Enter is pressed.
  25.  
  26.        The string between the quotes will be  displayed  as  the  prompt
  27.        line.
  28.  
  29.        If the /F  (or  /f)  option  is  used,  F1  -  F10  become  valid
  30.        responses.
  31.  
  32.        Return ERRORLEVELS
  33.  
  34.        Function keys return their extended code plus 100.
  35.  
  36.        F1  159    F2  160    F3  161    F4  162    F5  163    F6  164
  37.        F7  165    F8  166    F9  167    F10 168
  38.  
  39.        Alphabetical  characters  "a  -  z"  and "A - Z" are converted to
  40.        ERRORLEVELS of 65 - 90 respectively.
  41.  
  42.        Remember that ERRORLEVELS must be tested from the highest to the
  43.        lowest value.  This is a DOS "feature".
  44.  
  45.        GETKEY entered with no command line parameters will cause the
  46.        program to exit with an ERRORLEVEL of 0 and print:
  47.  
  48.        Useage: GETKEY [/F] "Prompt" [XYZ]',13,10,'$'
  49.  
  50.  
  51.  
  52.        Some Examples
  53.  
  54.        Here is a simple (minded) batch file do demo the use of GETKEY
  55.        using the /F option.  You can cut it out with and editor and
  56.        execute it if you desire.
  57.  
  58.        MYMENU.BAT
  59.  
  60.        echo off
  61.        :begin
  62.        cls
  63.        Echo.
  64.        Echo.
  65.        Echo                                   MY MENU
  66.        Echo.
  67.        Echo                             F1   Directory
  68.        Echo                             F2   Wide Directory
  69.        Echo                             F3   Print Directory
  70.        Echo                             F4   Save Dir to MYDIR
  71.        Echo                             F5   Directory of A:
  72.        Echo                             F6   CHKDSK
  73.        Echo                             F7   Date
  74.        Echo                             F8   Time
  75.        Echo                             F9   DOS Version
  76.        Echo                             F10  Exit to DOS
  77.        Echo.
  78.        GETKEY /F "                            Select: "
  79.        if ERRORLEVEL==168 goto exit
  80.        if ERRORLEVEL==167 goto version
  81.        if ERRORLEVEL==166 goto time
  82.        if ERRORLEVEL==165 goto date
  83.        if ERRORLEVEL==164 goto chkdsk
  84.        if ERRORLEVEL==163 goto dira
  85.        if ERRORLEVEL==162 goto dirsave
  86.        if ERRORLEVEL==161 goto printdir
  87.        if ERRORLEVEL==160 goto dirwide
  88.        if ERRORLEVEL==159 goto dir
  89.        goto begin
  90.  
  91.        :dir
  92.        echo.
  93.        dir /p
  94.        pause
  95.        goto begin
  96.  
  97.        :dirwide
  98.        echo.
  99.        dir /w/p
  100.        pause
  101.        goto begin
  102.  
  103.        :printdir
  104.        echo.
  105.        dir > lpt1
  106.        goto begin
  107.  
  108.        :dirsave
  109.        echo.
  110.        dir > mydir
  111.        goto begin
  112.  
  113.        :dira
  114.        echo.
  115.        dir a: /p
  116.        pause
  117.        goto begin
  118.  
  119.        :chkdsk
  120.        echo.
  121.        chkdsk
  122.        pause
  123.        goto begin
  124.  
  125.        :date
  126.        echo.
  127.        date
  128.        pause
  129.        goto begin
  130.  
  131.        :time
  132.        echo.
  133.        time
  134.        pause
  135.        goto begin
  136.  
  137.        :version
  138.        echo.
  139.        ver
  140.        pause
  141.        goto begin
  142.  
  143.        :exit
  144.        echo.
  145.        Echo Have a nice day!
  146.  
  147.        If you don't use all of the funtion keys, test for the lowest
  148.        value you DON'T want and do a "goto begin".
  149.  
  150.  
  151.        Example 2
  152.  
  153.        Here is a very simple batch file to illustrate the valid options
  154.        and the default enter.  With this batch file, and Enter is the
  155.        same as a Yes answer.
  156.  
  157.        DIRP.BAT
  158.  
  159.        Echo off
  160.        CLS
  161.        echo.
  162.        echo.
  163.        echo.
  164.        GETKEY "Do you want a DIRectory? [Y/n] " ny
  165.  
  166.        if ERRORLEVEL==89 goto yes
  167.        goto exit
  168.  
  169.        :yes
  170.        echo.
  171.        echo.
  172.        dir /p
  173.  
  174.        :exit
  175.  
  176.        Note also that only the "Y" is tested for.  The "N" is the only
  177.        other option so it is not necessary to test for it.
  178.  
  179.  
  180.        Disclaimer
  181.  
  182.        This  program  is  donated to the public domain.  Since no fee is
  183.        requested, no responsibility on my part  is  assumed.   Use  this
  184.        program  entirely  at  your  own risk.  By using this program you
  185.        assume ALL responsibility for ANYTHING that happens.  While  this
  186.        program  works  fine  on  my  AT  compatible,  it may not on your
  187.        system.  The only thing promised is that it will take up space on
  188.        your disk!
  189.  
  190.        \/\/alter
  191.  
  192.